package com.anjoyo.xgh.musicshare.adapter;

import java.util.List;

import android.R.integer;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;

public class MyPagerAdapter extends PagerAdapter {

	List<View> views;
	int tem;
	public MyPagerAdapter(List<View> views) {
		this.views = views;
	}

	@Override
	public int getCount() {
//		return views.size();
		return Integer.MAX_VALUE;
	}

	@Override
	public boolean isViewFromObject(View view, Object arg1) {
		return view == arg1;
	}

	@Override
	public void destroyItem(ViewGroup container, int position, Object object) {
//		System.out.println("移除"+position);
//		((ViewPager) container).removeView(views.get(position));
		
	}
	@Override
	public Object instantiateItem(ViewGroup container, int position) {
//		System.out.println("添加"+position);
//		((ViewPager) container).addView(views.get(position));
//		return views.get(position);
		int newPosition = position%views.size();
		((ViewPager) container).removeView(views.get(newPosition));
		((ViewPager) container).addView(views.get(newPosition));
		return views.get(newPosition);
	}
}
